package zb.wzby;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * @author wzby
 * @Date: 2022/8/10 17:29
 */
public class Ex2 {
    public static void main(String[] args) {
        for (int i = 1; i < 20; i++) {
            Thread sstr = new Thread(() -> {
                String str = Thread.currentThread().getName();
                System.out.printf("%s开始%n", str);
                Random rand = new Random();
                try {
                    TimeUnit.SECONDS.sleep(rand.nextInt(1, 5));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                System.out.printf("%s结束%n", str);
            }, "EXtwo" + i);
            try {
                sstr.start();
                sstr.join();
            } catch (InterruptedException e) {
                throw new RuntimeException();
            }
        }
        System.out.println("gogogo已完成!!!");
    }
}
